@buerli.io/core 1.0.1 → 1.1.0-beta.8
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/README.md +19 -19
- package/build/cjs/geometry/ThreeGeometryCreator.js +320 -320
- package/build/cjs/geometry/index.js +17 -17
- package/build/cjs/graphic/filters.js +25 -25
- package/build/cjs/index.js +26 -26
- package/build/cjs/re-export.js +29 -29
- package/build/cjs/store/index.js +41 -37
- package/build/cjs/store/states/buerli.js +98 -98
- package/build/cjs/store/states/cad.js +47 -47
- package/build/cjs/store/states/drawing.js +49 -49
- package/build/cjs/store/states/geometry.js +157 -157
- package/build/cjs/store/states/graphic.js +115 -115
- package/build/cjs/store/states/interaction.js +55 -55
- package/build/cjs/store/states/message.js +32 -25
- package/build/cjs/store/states/plugin.js +115 -115
- package/build/cjs/store/states/selection.js +267 -267
- package/build/cjs/store/states/structure.js +250 -250
- package/build/cjs/store/store.js +9 -9
- package/build/cjs/store/subscribtion/selection.js +49 -49
- package/build/cjs/store/subscribtion/subscribeToDrawing.js +13 -13
- package/build/cjs/types/InteractionInfo.js +11 -11
- package/build/cjs/types/index.js +34 -34
- package/build/cjs/utils/Math.js +91 -91
- package/build/cjs/utils/Measure.js +576 -576
- package/build/cjs/utils/Timing.js +34 -34
- package/build/esm/geometry/ThreeGeometryCreator.js +291 -291
- package/build/esm/geometry/index.js +1 -1
- package/build/esm/graphic/filters.js +12 -12
- package/build/esm/index.js +10 -10
- package/build/esm/re-export.js +23 -23
- package/build/esm/store/index.js +29 -26
- package/build/esm/store/states/buerli.js +92 -92
- package/build/esm/store/states/cad.js +42 -42
- package/build/esm/store/states/drawing.js +45 -45
- package/build/esm/store/states/geometry.js +129 -129
- package/build/esm/store/states/graphic.js +110 -110
- package/build/esm/store/states/interaction.js +50 -50
- package/build/esm/store/states/message.js +28 -21
- package/build/esm/store/states/plugin.js +109 -109
- package/build/esm/store/states/selection.js +261 -261
- package/build/esm/store/states/structure.js +219 -219
- package/build/esm/store/store.js +3 -3
- package/build/esm/store/subscribtion/selection.js +44 -44
- package/build/esm/store/subscribtion/subscribeToDrawing.js +9 -9
- package/build/esm/types/InteractionInfo.js +6 -6
- package/build/esm/types/index.js +16 -16
- package/build/esm/utils/Math.js +65 -65
- package/build/esm/utils/Measure.js +550 -550
- package/build/esm/utils/Timing.js +31 -31
- package/build/types/geometry/ThreeGeometryCreator.d.ts +256 -256
- package/build/types/geometry/index.d.ts +1 -1
- package/build/types/graphic/filters.d.ts +11 -11
- package/build/types/index.d.ts +38 -38
- package/build/types/re-export.d.ts +70 -70
- package/build/types/store/index.d.ts +17 -16
- package/build/types/store/states/buerli.d.ts +41 -41
- package/build/types/store/states/cad.d.ts +56 -56
- package/build/types/store/states/drawing.d.ts +45 -45
- package/build/types/store/states/geometry.d.ts +64 -64
- package/build/types/store/states/graphic.d.ts +21 -21
- package/build/types/store/states/interaction.d.ts +34 -34
- package/build/types/store/states/message.d.ts +32 -30
- package/build/types/store/states/plugin.d.ts +53 -53
- package/build/types/store/states/selection.d.ts +69 -69
- package/build/types/store/states/structure.d.ts +47 -47
- package/build/types/store/store.d.ts +2 -2
- package/build/types/store/subscribtion/selection.d.ts +7 -7
- package/build/types/store/subscribtion/subscribeToDrawing.d.ts +4 -4
- package/build/types/types/InteractionInfo.d.ts +42 -42
- package/build/types/types/index.d.ts +7 -7
- package/build/types/utils/Math.d.ts +21 -21
- package/build/types/utils/Measure.d.ts +64 -64
- package/build/types/utils/Timing.d.ts +8 -8
- package/package.json +2 -2
package/build/esm/utils/Math.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
const degToRad = THREE.MathUtils.degToRad;
|
|
3
|
-
const tolerance = 1e-6;
|
|
4
|
-
export const MathUtils = {
|
|
5
|
-
convertToMatrix4: function (coordinateSystem) {
|
|
6
|
-
const [orig, vx, vy, vz] = coordinateSystem.map(row => new THREE.Vector3().fromArray(row));
|
|
7
|
-
return new THREE.Matrix4().makeBasis(vx, vy, vz).setPosition(orig);
|
|
8
|
-
},
|
|
9
|
-
convertToMatrix3: function (coordinateSystem) {
|
|
10
|
-
const [, vx, vy, vz] = coordinateSystem;
|
|
11
|
-
return new THREE.Matrix3().fromArray([...vx, ...vy, ...vz]);
|
|
12
|
-
},
|
|
13
|
-
convertToCoordinateSystem: function (matrix) {
|
|
14
|
-
const position = new THREE.Vector3();
|
|
15
|
-
const xAxis = new THREE.Vector3();
|
|
16
|
-
const yAxis = new THREE.Vector3();
|
|
17
|
-
const zAxis = new THREE.Vector3();
|
|
18
|
-
position.setFromMatrixPosition(matrix);
|
|
19
|
-
matrix.extractBasis(xAxis, yAxis, zAxis);
|
|
20
|
-
const coordSys = [];
|
|
21
|
-
coordSys[0] = [position.x, position.y, position.z];
|
|
22
|
-
coordSys[1] = [xAxis.x, xAxis.y, xAxis.z];
|
|
23
|
-
coordSys[2] = [yAxis.x, yAxis.y, yAxis.z];
|
|
24
|
-
coordSys[3] = [zAxis.x, zAxis.y, zAxis.z];
|
|
25
|
-
return coordSys;
|
|
26
|
-
},
|
|
27
|
-
round(value, digits) {
|
|
28
|
-
if (isNaN(value))
|
|
29
|
-
return NaN;
|
|
30
|
-
const factor = Math.pow(10, digits);
|
|
31
|
-
return Math.round(value * factor) / factor;
|
|
32
|
-
},
|
|
33
|
-
/**
|
|
34
|
-
* Calculates a transformation matrix.
|
|
35
|
-
*
|
|
36
|
-
* xDir and yDir are NOT orthogonal in general case, thus the y-axis is calculated as a series of cross products.
|
|
37
|
-
*
|
|
38
|
-
* @param originPos The origin position.
|
|
39
|
-
* @param xDir The x direction.
|
|
40
|
-
* @param yDir The y direction.
|
|
41
|
-
* @param offset The offset vector.
|
|
42
|
-
* @param rotation The rotation vector.
|
|
43
|
-
* @param inverted The inverted flag --- 0: do not invert; 1: do invert.
|
|
44
|
-
* @returns The calculated THREE.Matrix4
|
|
45
|
-
*/
|
|
46
|
-
calcluateTransform: function (originPos, xDir, yDir, offset, rotation, inverted) {
|
|
47
|
-
rotation = new THREE.Vector3(degToRad(rotation.x), degToRad(rotation.y), degToRad(rotation.z));
|
|
48
|
-
const xAxis = xDir.clone().normalize();
|
|
49
|
-
let yDir_ = yDir.clone().normalize();
|
|
50
|
-
if (Math.abs(yDir_.dot(xAxis.clone())) > 1 - tolerance) {
|
|
51
|
-
yDir_ = Math.abs(xAxis.y) !== 1 ? new THREE.Vector3(0.0, 1.0, 0.0) : new THREE.Vector3(1.0, 0.0, 0.0);
|
|
52
|
-
}
|
|
53
|
-
const zAxis = xAxis.clone().cross(yDir_).normalize();
|
|
54
|
-
const yAxis = zAxis.clone().cross(xAxis).normalize();
|
|
55
|
-
if (inverted) {
|
|
56
|
-
xAxis.negate();
|
|
57
|
-
zAxis.negate();
|
|
58
|
-
}
|
|
59
|
-
const mLocal = new THREE.Matrix4()
|
|
60
|
-
.makeRotationFromEuler(new THREE.Euler(rotation.x, rotation.y, rotation.z))
|
|
61
|
-
.setPosition(offset.x, offset.y, offset.z);
|
|
62
|
-
const mGlobal = new THREE.Matrix4().makeBasis(xAxis, yAxis, zAxis).setPosition(originPos);
|
|
63
|
-
return mGlobal.clone().multiply(mLocal);
|
|
64
|
-
},
|
|
65
|
-
};
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
const degToRad = THREE.MathUtils.degToRad;
|
|
3
|
+
const tolerance = 1e-6;
|
|
4
|
+
export const MathUtils = {
|
|
5
|
+
convertToMatrix4: function (coordinateSystem) {
|
|
6
|
+
const [orig, vx, vy, vz] = coordinateSystem.map(row => new THREE.Vector3().fromArray(row));
|
|
7
|
+
return new THREE.Matrix4().makeBasis(vx, vy, vz).setPosition(orig);
|
|
8
|
+
},
|
|
9
|
+
convertToMatrix3: function (coordinateSystem) {
|
|
10
|
+
const [, vx, vy, vz] = coordinateSystem;
|
|
11
|
+
return new THREE.Matrix3().fromArray([...vx, ...vy, ...vz]);
|
|
12
|
+
},
|
|
13
|
+
convertToCoordinateSystem: function (matrix) {
|
|
14
|
+
const position = new THREE.Vector3();
|
|
15
|
+
const xAxis = new THREE.Vector3();
|
|
16
|
+
const yAxis = new THREE.Vector3();
|
|
17
|
+
const zAxis = new THREE.Vector3();
|
|
18
|
+
position.setFromMatrixPosition(matrix);
|
|
19
|
+
matrix.extractBasis(xAxis, yAxis, zAxis);
|
|
20
|
+
const coordSys = [];
|
|
21
|
+
coordSys[0] = [position.x, position.y, position.z];
|
|
22
|
+
coordSys[1] = [xAxis.x, xAxis.y, xAxis.z];
|
|
23
|
+
coordSys[2] = [yAxis.x, yAxis.y, yAxis.z];
|
|
24
|
+
coordSys[3] = [zAxis.x, zAxis.y, zAxis.z];
|
|
25
|
+
return coordSys;
|
|
26
|
+
},
|
|
27
|
+
round(value, digits) {
|
|
28
|
+
if (isNaN(value))
|
|
29
|
+
return NaN;
|
|
30
|
+
const factor = Math.pow(10, digits);
|
|
31
|
+
return Math.round(value * factor) / factor;
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* Calculates a transformation matrix.
|
|
35
|
+
*
|
|
36
|
+
* xDir and yDir are NOT orthogonal in general case, thus the y-axis is calculated as a series of cross products.
|
|
37
|
+
*
|
|
38
|
+
* @param originPos The origin position.
|
|
39
|
+
* @param xDir The x direction.
|
|
40
|
+
* @param yDir The y direction.
|
|
41
|
+
* @param offset The offset vector.
|
|
42
|
+
* @param rotation The rotation vector.
|
|
43
|
+
* @param inverted The inverted flag --- 0: do not invert; 1: do invert.
|
|
44
|
+
* @returns The calculated THREE.Matrix4
|
|
45
|
+
*/
|
|
46
|
+
calcluateTransform: function (originPos, xDir, yDir, offset, rotation, inverted) {
|
|
47
|
+
rotation = new THREE.Vector3(degToRad(rotation.x), degToRad(rotation.y), degToRad(rotation.z));
|
|
48
|
+
const xAxis = xDir.clone().normalize();
|
|
49
|
+
let yDir_ = yDir.clone().normalize();
|
|
50
|
+
if (Math.abs(yDir_.dot(xAxis.clone())) > 1 - tolerance) {
|
|
51
|
+
yDir_ = Math.abs(xAxis.y) !== 1 ? new THREE.Vector3(0.0, 1.0, 0.0) : new THREE.Vector3(1.0, 0.0, 0.0);
|
|
52
|
+
}
|
|
53
|
+
const zAxis = xAxis.clone().cross(yDir_).normalize();
|
|
54
|
+
const yAxis = zAxis.clone().cross(xAxis).normalize();
|
|
55
|
+
if (inverted) {
|
|
56
|
+
xAxis.negate();
|
|
57
|
+
zAxis.negate();
|
|
58
|
+
}
|
|
59
|
+
const mLocal = new THREE.Matrix4()
|
|
60
|
+
.makeRotationFromEuler(new THREE.Euler(rotation.x, rotation.y, rotation.z))
|
|
61
|
+
.setPosition(offset.x, offset.y, offset.z);
|
|
62
|
+
const mGlobal = new THREE.Matrix4().makeBasis(xAxis, yAxis, zAxis).setPosition(originPos);
|
|
63
|
+
return mGlobal.clone().multiply(mLocal);
|
|
64
|
+
},
|
|
65
|
+
};
|