@xeokit/xeokit-sdk 2.6.65 → 2.6.66

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.65",
3
+ "version": "2.6.66",
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",
@@ -87,7 +87,7 @@ export class PointerCircle {
87
87
  }
88
88
 
89
89
  /**
90
- * Stop the shricking circle and hide it.
90
+ * Stop the shrinking circle and hide it.
91
91
  */
92
92
  stop() {
93
93
  if (this._destroyed) {
@@ -132,15 +132,13 @@ class Control {
132
132
  });
133
133
 
134
134
  const handlers = { };
135
- const addAxis = (rgb, axisDirection, hoopDirection) => {
135
+ const addAxis = (rgb, hoopRot) => {
136
+ const axisDirection = math.mulVec3Scalar(rgb, -1, math.vec3());
136
137
  const material = colorMaterial(rgb);
137
138
 
138
- const rotateToHorizontal = math.rotationMat4v(270 * math.DEGTORAD, [1, 0, 0], math.identityMat4());
139
- const hoopRotation = math.quaternionToRotationMat4(math.vec3PairToQuaternion([ 0, 1, 0 ], hoopDirection), math.identityMat4());
140
- const hoopMatrix = math.mulMat4(hoopRotation, rotateToHorizontal, math.identityMat4());
141
-
139
+ const hoopMatrix = math.quaternionToRotationMat4(hoopRot, math.identityMat4());
140
+ math.mulMat4(math.rotationMat4v(Math.PI, [0,1,0], math.mat4()), hoopMatrix, hoopMatrix);
142
141
  const scale = math.scaleMat4v([0.6, 0.6, 0.6], math.identityMat4());
143
-
144
142
  const scaledArrowMatrix = (t, matR) => {
145
143
  const matT = math.translateMat4v(t, math.identityMat4());
146
144
  const ret = math.identityMat4();
@@ -209,7 +207,8 @@ class Control {
209
207
  }), NO_STATE_INHERIT);
210
208
 
211
209
 
212
- const axisRotation = math.quaternionToRotationMat4(math.vec3PairToQuaternion([ 0, 1, 0 ], axisDirection), math.identityMat4());
210
+ const axisRotation = math.quaternionToRotationMat4(math.vec3PairToQuaternion([ 0, 1, 0 ], rgb), math.identityMat4());
211
+ math.mulMat4(math.rotationMat4v(Math.PI, [0,1,0], math.mat4()), axisRotation, axisRotation);
213
212
 
214
213
  const translatedAxisMatrix = (yOffset) => math.mulMat4(axisRotation, math.translateMat4c(0, yOffset, 0, math.identityMat4()), math.identityMat4());
215
214
  const arrowMatrix = translatedAxisMatrix(arrowLength + .1);
@@ -338,7 +337,7 @@ class Control {
338
337
  rootNode.rotate(rgb, (rotation - lastRotation) * 180 / Math.PI);
339
338
  if (this._sectionPlane) {
340
339
  ignoreNextSectionPlaneDirUpdate = true;
341
- this._sectionPlane.dir = math.vec3ApplyQuaternion(rootNode.quaternion, [0, 0, 1], tempVec3);
340
+ this._sectionPlane.quaternion = rootNode.quaternion;
342
341
  }
343
342
  lastRotation = rotation;
344
343
  };
@@ -452,9 +451,9 @@ class Control {
452
451
  //
453
452
  //----------------------------------------------------------------------------------------------------------
454
453
 
455
- addAxis([1,0,0], [ 1, 0, 0 ], [ 1, 0, 0 ]),
456
- addAxis([0,1,0], [ 0, -1, 0 ], [ 0, 1, 0 ]),
457
- addAxis([0,0,1], [ 0, 0, -1 ], [ 0, 0, -1 ])
454
+ addAxis([1,0,0], math.vec3PairToQuaternion([1,0,0], [0,0,1])),
455
+ addAxis([0,1,0], math.eulerToQuaternion([90,0,0], "XYZ")),
456
+ addAxis([0,0,1], math.identityQuaternion())
458
457
  ];
459
458
 
460
459
  const cleanups = [ ];
@@ -592,7 +591,7 @@ class Control {
592
591
  this.id = sectionPlane.id;
593
592
  this._sectionPlane = sectionPlane;
594
593
  const setPosFromSectionPlane = () => setPos(sectionPlane.pos);
595
- const setDirFromSectionPlane = () => rootNode.quaternion = math.vec3PairToQuaternion(zeroVec, sectionPlane.dir, quat);
594
+ const setDirFromSectionPlane = () => rootNode.quaternion = sectionPlane.quaternion;
596
595
  setPosFromSectionPlane();
597
596
  setDirFromSectionPlane();
598
597
  const onSectionPlanePos = sectionPlane.on("pos", setPosFromSectionPlane);
@@ -1563,6 +1563,7 @@ export class SceneModel extends Component {
1563
1563
  set matrix(value) {
1564
1564
  this._matrix.set(value || DEFAULT_MATRIX);
1565
1565
  math.decomposeMat4(this._matrix, this._position, this._quaternion, this._scale);
1566
+ math.quaternionToEuler(this._quaternion, "XYZ", this._rotation);
1566
1567
  this._matrixDirty = false;
1567
1568
  this._setWorldMatrixDirty();
1568
1569
  this._sceneModelDirty();
@@ -221,7 +221,10 @@ export class TrianglesColorRenderer extends TrianglesBatchingRenderer {
221
221
  }
222
222
 
223
223
  if (scene.logarithmicDepthBufferEnabled) {
224
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
224
+ src.push(" float dx = dFdx(vFragDepth);")
225
+ src.push(" float dy = dFdy(vFragDepth);")
226
+ src.push(" float diff = sqrt(dx*dx+dy*dy);");
227
+ src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");
225
228
  }
226
229
 
227
230
  if (this._withSAO) {
@@ -234,7 +234,10 @@ class TrianglesColorRenderer extends TrianglesInstancingRenderer {
234
234
  }
235
235
 
236
236
  if (scene.logarithmicDepthBufferEnabled) {
237
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
237
+ src.push(" float dx = dFdx(vFragDepth);")
238
+ src.push(" float dy = dFdy(vFragDepth);")
239
+ src.push(" float diff = sqrt(dx*dx+dy*dy);");
240
+ src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");
238
241
  }
239
242
 
240
243
  // Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
@@ -3,6 +3,11 @@ import {RenderState} from '../webgl/RenderState.js';
3
3
  import {math} from "../math/math.js";
4
4
 
5
5
  const tempVec3a = math.vec3();
6
+ const tempVec3b = math.vec3();
7
+ const tempVec4a = math.vec4();
8
+ const front = math.vec3([0, 0, -1]);
9
+ const back = math.vec3([0, 0, 1]);
10
+ const up = math.vec3([0, 1, 0]);
6
11
 
7
12
  /**
8
13
  * @desc An arbitrarily-aligned World-space clipping plane.
@@ -74,6 +79,8 @@ class SectionPlane extends Component {
74
79
  this._state = new RenderState({
75
80
  active: true,
76
81
  pos: math.vec3(),
82
+ quaternion: math.vec4(),
83
+ roll: 0,
77
84
  dir: math.vec3(),
78
85
  dist: 0
79
86
  });
@@ -135,6 +142,59 @@ class SectionPlane extends Component {
135
142
  return this._state.pos;
136
143
  }
137
144
 
145
+ /**
146
+ * Sets the quaternion of this SectionPlane's plane.
147
+ *
148
+ * Default value is ````[0, -1, 0, 0]````.
149
+ *
150
+ * @param {Number[]} value New quaternion.
151
+ */
152
+ set quaternion(value) {
153
+ this._state.quaternion.set(value || [0, 0, 0, -1]);
154
+ math.vec3ApplyQuaternion(this._state.quaternion, back, this._state.dir);
155
+ const quatUp = math.vec3ApplyQuaternion(this._state.quaternion, up, tempVec3a);
156
+ const dirOnlyQ = math.vec3PairToQuaternion(back, this._state.dir, tempVec4a);
157
+ const dirOnlyUp = math.vec3ApplyQuaternion(dirOnlyQ, up, tempVec3b);
158
+ const angle = Math.acos(Math.min(1, math.dotVec3(quatUp, dirOnlyUp)));
159
+ const sign = Math.sign(math.dotVec3(this._state.dir, math.cross3Vec3(quatUp, dirOnlyUp, tempVec3b)));
160
+ this._state.roll = sign * angle;
161
+ this._onDirUpdated();
162
+ }
163
+
164
+ /**
165
+ * Gets the quaternion of this SectionPlane's plane.
166
+ *
167
+ * Default value is ````[0, -1, 0, 0]````.
168
+ *
169
+ * @returns {Number[]} value Current quaternion.
170
+ */
171
+ get quaternion() {
172
+ return this._state.quaternion;
173
+ }
174
+
175
+ /**
176
+ * Sets the roll of this SectionPlane's plane.
177
+ *
178
+ * Default value is ````0````.
179
+ *
180
+ * @param {Number[]} value New roll.
181
+ */
182
+ set roll(value) {
183
+ this._state.roll = value || 0;
184
+ this._onDirRollUpdated();
185
+ }
186
+
187
+ /**
188
+ * Gets the roll of this SectionPlane's plane.
189
+ *
190
+ * Default value is ````0````.
191
+ *
192
+ * @returns {Number[]} value Current roll.
193
+ */
194
+ get roll() {
195
+ return this._state.roll;
196
+ }
197
+
138
198
  /**
139
199
  * Sets the direction of this SectionPlane's plane.
140
200
  *
@@ -143,7 +203,25 @@ class SectionPlane extends Component {
143
203
  * @param {Number[]} value New direction.
144
204
  */
145
205
  set dir(value) {
146
- this._state.dir.set(value || [0, 0, -1]);
206
+ this._state.dir.set(value || front);
207
+ this._onDirRollUpdated();
208
+ }
209
+
210
+ _onDirRollUpdated() {
211
+ math.vec3PairToQuaternion(back, this._state.dir, this._state.quaternion);
212
+
213
+ tempVec4a[0] = 0;
214
+ tempVec4a[1] = 0;
215
+ tempVec4a[2] = -1;
216
+ tempVec4a[3] = this._state.roll;
217
+ math.angleAxisToQuaternion(tempVec4a, tempVec4a);
218
+
219
+ math.mulQuaternions(this._state.quaternion, tempVec4a, this._state.quaternion);
220
+
221
+ this._onDirUpdated();
222
+ }
223
+
224
+ _onDirUpdated() {
147
225
  this._state.dist = (-math.dotVec3(this._state.pos, this._state.dir));
148
226
  this.glRedraw();
149
227
  this.fire("dir", this._state.dir);
@@ -935,6 +935,9 @@ const Renderer = function (scene, options) {
935
935
  pickProjMatrix = scene.camera.projMatrix;
936
936
  projection = scene.camera.projection;
937
937
 
938
+ nearAndFar[0] = scene.camera.project.near;
939
+ nearAndFar[1] = scene.camera.project.far;
940
+
938
941
  pickResult.canvasPos = params.canvasPos;
939
942
 
940
943
  } else {
@@ -948,6 +951,9 @@ const Renderer = function (scene, options) {
948
951
  pickProjMatrix = scene.camera.projMatrix;
949
952
  projection = scene.camera.projection;
950
953
 
954
+ nearAndFar[0] = scene.camera.project.near;
955
+ nearAndFar[1] = scene.camera.project.far;
956
+
951
957
  } else {
952
958
 
953
959
  worldRayOrigin.set(params.origin || [0, 0, 0]);
@@ -967,6 +973,9 @@ const Renderer = function (scene, options) {
967
973
  pickProjMatrix = scene.camera.ortho.matrix;
968
974
  projection = "ortho";
969
975
 
976
+ nearAndFar[0] = scene.camera.ortho.near;
977
+ nearAndFar[1] = scene.camera.ortho.far;
978
+
970
979
  pickResult.origin = worldRayOrigin;
971
980
  pickResult.direction = worldRayDir;
972
981
  }
@@ -1021,9 +1030,6 @@ const Renderer = function (scene, options) {
1021
1030
 
1022
1031
  if (pickable.canPickWorldPos && pickable.canPickWorldPos()) {
1023
1032
 
1024
- nearAndFar[0] = scene.camera.project.near;
1025
- nearAndFar[1] = scene.camera.project.far;
1026
-
1027
1033
  gpuPickWorldPos(pickBuffer, pickable, canvasPos, pickViewMatrix, pickProjMatrix, nearAndFar, pickResult);
1028
1034
 
1029
1035
  if (params.pickSurfaceNormal !== false) {
@@ -0,0 +1,50 @@
1
+ import {Viewer} from "../../viewer";
2
+
3
+ /**
4
+ * A PointerCircle shows a circle, centered at the position of the
5
+ * mouse or touch pointer.
6
+ */
7
+ export class PointerCircle {
8
+ /**
9
+ * Constructs a new PointerCircle.
10
+ * @param {Viewer} viewer The Viewer
11
+ * @param {Object} [cfg] PointerCircle configuration.
12
+ * @param {boolean} [cfg.active=true] Whether PointerCircle is active. The PointerCircle can only be shown when this is `true` (default).
13
+ */
14
+ constructor(viewer: Viewer, cfg?: {
15
+ active?: boolean;
16
+ });
17
+
18
+ /**
19
+ * Show the circle at the given canvas coordinates and begin shrinking it.
20
+ */
21
+ start(circlePos: number[]): void;
22
+
23
+ /**
24
+ * Stop the shrinking circle and hide it.
25
+ */
26
+ stop(): void;
27
+
28
+ /**
29
+ * Sets the zoom factor for the lens.
30
+ *
31
+ * This is `2` by default.
32
+ *
33
+ * @param {number} durationMs
34
+ */
35
+ set durationMs(durationMs: number);
36
+
37
+ /**
38
+ * Gets the zoom factor for the lens.
39
+ *
40
+ * This is `2` by default.
41
+ *
42
+ * @returns {number} Number
43
+ */
44
+ get durationMs(): number;
45
+
46
+ /**
47
+ * Destroys this PointerCircle.
48
+ */
49
+ destroy(): void;
50
+ }
@@ -0,0 +1 @@
1
+ export * from "./PointerCircle";
@@ -19,6 +19,7 @@ export * from "./ViewCullPlugin";
19
19
  export * from "./XKTLoaderPlugin";
20
20
  export * from "./WebIFCLoaderPlugin";
21
21
  export * from "./XML3DLoaderPlugin";
22
+ export * from "./lib/ui";
22
23
 
23
24
  export declare type ModelStats = {
24
25
  sourceFormat: string;
@@ -0,0 +1,12 @@
1
+ import { Viewer } from "../../../viewer";
2
+ import { PointerCircle } from "../../../extras/PointerCircle";
3
+
4
+ type Cleanup = () => void;
5
+
6
+ type OnCancel = () => void;
7
+ type OnChange = () => void;
8
+ type OnCommit = () => void;
9
+
10
+ type Ray2WorldPos = (origin: number[], direction: number[]) => boolean | number[];
11
+
12
+ declare function touchPointSelector(viewer: Viewer, pointerCircle: PointerCircle, ray2WorldPos: Ray2WorldPos): (onCancel: OnCancel, onChange: OnChange, onCommit: OnCommit) => Cleanup;